Skip to content

fix(test): out-of-process watchdog for the httpapi exerciser - #177

Merged
LeXwDeX merged 1 commit into
devfrom
fix/httpapi-exerciser-watchdog
Aug 5, 2026
Merged

fix(test): out-of-process watchdog for the httpapi exerciser#177
LeXwDeX merged 1 commit into
devfrom
fix/httpapi-exerciser-watchdog

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Aug 5, 2026

Copy link
Copy Markdown
Owner

起因(2026-08-05 CI 事故)

merge #176 推 main 触发的全量 CI(run 30968399761)中,Run HttpAPI Exerciser Gatesworktree.create: shared use done 之后静默卡死 13 分钟直到步骤 15 分钟硬超时。重跑即过(同代码 40 分钟前在 dev 也全绿)——罕见 flake,非 #176 引入的回归。

根因分析

exerciser 现有的两层防线都是基于定时器的:

  1. 30s 场景超时(Effect.timeoutOrElse)——Effect 中断无法打断阻塞在永不 settle 的原生 Promise / 卡死原生调用上的 fiber
  2. 2026-07-27 事故后加的 bounded() 清理守卫——用 setTimeout + Promise.race 兜底

两层都要求 JS 事件循环还在转。本次卡死的形态(13 分钟零输出)说明事件循环整体冻结(实例 dispose / tree-sitter / sqlite 原生清理死锁类)——此时所有进程内守卫与事件循环同归于尽,什么都不会触发。

能救冻结事件循环的守卫只有独立进程。

修复

  • runner 在每个 scenario/phase 转移时向心跳文件写最后活动(--progress 模式,即 CI)
  • 子进程每 5s 轮询心跳;静默 120s 即打印最后的 scenario/phase 归属并 SIGKILL 主进程
  • 静默 15 分钟的卡死 → 2 分钟内带归属信息的失败;步骤 15 分钟超时保留为最后兜底
  • 父进程退出后看门狗子进程自行退出(探测父进程存活)

验证

  • typecheck ✓
  • worktree 场景子集(5 个)带看门狗全过,正常路径无误杀
  • 合成事件循环冻结测试:3s 超时 + 1s 轮询下约 4s 被杀,输出 [watchdog] no progress for 4s; last activity: phase-two: about to freeze — killing pid,exit 137

2026-08-05 CI incident: the effect-mode run froze for 13 minutes with zero output after "worktree.create: shared use done" until the 15m step timeout. The scenario timeout and the bounded() cleanup guards are all timer-based — they cannot fire when a native-level hang (instance dispose / tree-sitter / sqlite teardown) freezes the event loop itself, which is the class of failure the 2026-07-27 hardening did not cover.

The only guard that survives a frozen event loop is a separate process:
- the runner heartbeats a file on every scenario/phase transition (--progress mode, i.e. CI)
- a child process polls it every 5s; after 120s of silence it prints the last recorded scenario/phase and SIGKILLs the runner
- a silent 15-minute freeze becomes a 2-minute attributed failure; the step timeout stays as the final backstop

Verified: worktree scenario subset passes with the watchdog armed; a synthetic event-loop freeze is killed in ~4s (3s timeout + poll) with the last-activity diagnostic, exit 137.
@LeXwDeX
LeXwDeX merged commit 9105f37 into dev Aug 5, 2026
5 checks passed
@LeXwDeX
LeXwDeX deleted the fix/httpapi-exerciser-watchdog branch August 5, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant